//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright 2007 CORE Solutions Limited
// All rights reserved.
// PROPRIETARY AND CONFIDENTIAL INFORMATION.
// Use is subject to license terms.
//
// FUNCTION ID      :   ACCESS_TEAM
// AUTHOR           :   Jerry Chen 
// DATE CREATE      :   2007/10/26
// DESCRIPTION      :   a COMMON UTIL file for the function, ACCESS_TEAM
//                  :   
//                  :   
//                  :   
//
// MODIFICATION HISTORY:
// DATE         AUTHOR          VERSION NO.         COMMENT
// -----------  --------------  ------------------  -------------------
// 2007/10/26   Jerry Chen      1.0                 source is generated.
//
//
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

package com.erp.app.setup.accessTeamMaster.bizLogic;

import java.sql.Connection;

import com.erp.app.common.ProjectConstants;
import com.erp.app.common.util.DocumentNumberGenerator;
import com.erp.app.setup.accessTeamMaster.vo.AccessTeamHdrVo;
import com.erp.framework.model.vo.SimpleBaseVo;

/**
* <p>A <strong>CommonUtil</strong> provides utility and helper functions
*  for other classes.
*
* @author          Jerry Chen 
* @version 1.0     2007/10/26
* @since           FrameWork 1.1
*
*/
public class AccessTeamCommonUtil {

	/**
	* Generates a unique document number.
	* @param      model   the incoming business model (VO)
	* @param      conn    the incoming connection
	*
	* @author     Jerry Chen 
	* @since      Framework 1.1
	*/
	public String generateDocumentNo(SimpleBaseVo model, Connection conn) throws Exception {

		final String PREFIX = "ACT";
		final String FIELD_NAME_ACCESS_TEAM_CODE = "ACCESS_TEAM_CODE";
		final int FIELD_NAME_ACCESS_TEAM_CODE_LENGTH = 6;

		AccessTeamHdrVo vo = (AccessTeamHdrVo) model;

		DocumentNumberGenerator dng = new DocumentNumberGenerator(vo.getCompanyCode(), ProjectConstants.DOC_TYPE_ACCESS_TEAM, FIELD_NAME_ACCESS_TEAM_CODE,
			DocumentNumberGenerator.YEAR_IGNORED, vo.getCreateUser(), PREFIX, conn);

		return dng.getAutoGenCode(FIELD_NAME_ACCESS_TEAM_CODE_LENGTH);

	}

	/**
	* Sets the primary key for non-standard or shared children, such as Item Task
	* @param      model   the incoming business model (VO)
	*
	* @author     Jerry Chen 
	* @since      Framework 1.1
	*/
	public void setPkForNonStandardChildren(SimpleBaseVo model) {

//		SoHdrVo vo = (SoHdrVo) model;
//		ChildList dtlList = vo.getChilds(ItemTaskVo.class);

//		if (dtlList != null && dtlList.size() > 0) {
//			for (int i=0; i<dtlList.size(); i++) {
//				ItemTaskVo dtlVo = (ItemTaskVo) dtlList.get(i);
//				if (CommonUtil.isEmpty(dtlVo.getDocumentNo())) {
//					dtlVo.setCompanyCode(vo.getCompanyCode());
//					dtlVo.setDocumentNo(vo.getSoNo());
//				}
//			}
//		}
	}

}
